
import { defineStore, type StoreDefinition } from 'pinia';
import { ref, type Ref, } from 'vue';
type BannerList = { title: string, src: string }[]

export const useUserStore: StoreDefinition = defineStore('user', () => {

  const imgModules = import.meta.glob('@/assets/images/p*.*')
  const bannerList: Ref<BannerList> = ref([])

  // 遍历图片模块，获取图片列表
  // 图片模块路径格式：@/assets/images/p{id}.{ext}
  // 图片列表格式：{ title: 'p{id}', src: '/public/images/p{id}.{ext}' }
  for (const path in imgModules) {
    bannerList.value.push({ title: path.split('/')[4].split('.')[0], src: path })
  }


  return {
    bannerList,
  }

})

